package com.mrogrape.notepad.activity.action.item;

import java.awt.event.ActionEvent;

import javax.swing.Action;
import javax.swing.JCheckBoxMenuItem;

import com.mrogrape.notepad.activity.action.NotepadAction;
import com.mrogrape.notepad.activity.entity.ViewSettings;
import com.mrogrape.notepad.data.ViewContext;
import com.mrogrape.notepad.resource.Settings;
import com.mrogrape.notepad.ui.StatusBar;


public class StateBarVisibleMenuItemAction extends NotepadAction {

	/** serialVersionUID */
	private static final long serialVersionUID = -1L;

	public StateBarVisibleMenuItemAction(){

		super.putValue(Action.NAME, "State Bar");
		super.putValue(Action.SHORT_DESCRIPTION, "Toggle State Bar Visible.");
	}

	@Override
	public void actionPerformed(ActionEvent ae) {

		JCheckBoxMenuItem item = (JCheckBoxMenuItem) ae.getSource();
		ViewSettings settings = Settings.getSettings().getViewSettings();
		
		StatusBar bar = ViewContext.getStatusBar();
		bar.setVisible(item.isSelected());
		settings.setStateBarVisible(item.isSelected());
	}
}
